home *** CD-ROM | disk | FTP | other *** search
/ 100 Plus Great Games 2 / 100PLUSV2.BIN / games / BaseDefender.dxr / 00010_Spaceship Scripts.ls < prev    next >
Encoding:
Text File  |  2002-01-25  |  32.2 KB  |  797 lines

  1. global shipData, shipSO, maxShips, bulletData, bulletSO, maxBullets, playerViewPoint, inputString
  2.  
  3. on initializeShips
  4.   shipData = []
  5.   repeat with wShip = 1 to maxShips
  6.     wSprite = shipSO + wShip
  7.     puppetSprite(wSprite, 1)
  8.     set the ink of sprite wSprite to 32
  9.     set the member of sprite wSprite to "Red Ship"
  10.     set the loc of sprite wSprite to point(-50, 100)
  11.     add(shipData, [0, 1, 1, [point(0, 0), point(0, 0), 0, 0], [0, 0, 0, 0]])
  12.   end repeat
  13. end
  14.  
  15. on initializeBullets
  16.   bulletData = []
  17.   repeat with wBullet = 1 to maxBullets
  18.     wSprite = bulletSO + wBullet
  19.     puppetSprite(wSprite, 1)
  20.     set the ink of sprite wSprite to 32
  21.     set the member of sprite wSprite to "Medium Cannon 1"
  22.     sprite(wSprite).locZ = 1000
  23.     set the loc of sprite wSprite to point(-50, 0)
  24.     add(bulletData, [0, 0, 0])
  25.   end repeat
  26. end
  27.  
  28. on initializeBulletReferenceIndex
  29.   global bulletReferenceIndex
  30.   bulletReferenceIndex = []
  31.   sequenceList = ["Light Cannon 1", "Light Cannon 2"]
  32.   particleProfile = [1, 0, 0]
  33.   launchSoundprofile = ["Normal Gun Round Two SFX"]
  34.   add(bulletReferenceIndex, [sequenceList, 20, 100, 5, particleProfile, 0, 6, launchSoundprofile])
  35.   sequenceList = ["Medium Cannon 1", "Medium Cannon 2"]
  36.   particleProfile = [2, 0, 0]
  37.   launchSoundprofile = ["laser Round One SFX"]
  38.   add(bulletReferenceIndex, [sequenceList, 35, 125, 9, particleProfile, 0, 10, launchSoundprofile])
  39.   sequenceList = ["Heavy Cannon 1", "Heavy Cannon 2"]
  40.   particleProfile = [3, 0, 0]
  41.   launchSoundprofile = ["Normal Gun Round One SFX"]
  42.   add(bulletReferenceIndex, [sequenceList, 25, 125, 10, particleProfile, 0, 12, launchSoundprofile])
  43.   sequenceList = ["Torpedo 1", "Torpedo 2"]
  44.   particleProfile = [8, 14, 6]
  45.   launchSoundprofile = ["Missile SFX"]
  46.   add(bulletReferenceIndex, [sequenceList, 140, 50, 10, particleProfile, 1, 35, launchSoundprofile])
  47.   sequenceList = ["Drone 1", "Drone 2", "Drone 3", "Drone 4", "Drone 5"]
  48.   particleProfile = [3, 6, 8]
  49.   launchSoundprofile = ["Laser Round Two SFX"]
  50.   add(bulletReferenceIndex, [sequenceList, 100, 40, 10, particleProfile, 1, 10, launchSoundprofile])
  51.   sequenceList = ["Dark Missile 1", "Dark Missile 2"]
  52.   particleProfile = [3, 13, 6]
  53.   launchSoundprofile = ["Missile SFX"]
  54.   add(bulletReferenceIndex, [sequenceList, 80, 45, 10, particleProfile, 1, 15, launchSoundprofile])
  55.   sequenceList = ["Torpedo 1", "Torpedo 2"]
  56.   particleProfile = [5, 12, 1]
  57.   launchSoundprofile = ["Mega Cannon SFX"]
  58.   add(bulletReferenceIndex, [sequenceList, 800, 250, 10, particleProfile, 2, 1000, launchSoundprofile])
  59.   sequenceList = ["Rocket 1", "Rocket 2"]
  60.   particleProfile = [8, 1, 1]
  61.   launchSoundprofile = ["Rocket SFX"]
  62.   add(bulletReferenceIndex, [sequenceList, 80, 125, 10, particleProfile, 0, 60, launchSoundprofile])
  63.   sequenceList = ["Rocket 1", "Rocket 2"]
  64.   particleProfile = [8, 6, 2]
  65.   launchSoundprofile = ["Missile SFX"]
  66.   add(bulletReferenceIndex, [sequenceList, 80, 125, 10, particleProfile, 1, 30, launchSoundprofile])
  67.   sequenceList = ["Laser Dot"]
  68.   particleProfile = [11, 0, 0]
  69.   launchSoundprofile = ["Mega Cannon SFX"]
  70.   add(bulletReferenceIndex, [sequenceList, 10, 200, 10, particleProfile, 0, 5, launchSoundprofile])
  71. end
  72.  
  73. on addBullet bOwner, bType, bLoc, bMomentum, bAim, btarget
  74.   global bulletReferenceIndex
  75.   validSlot = 0
  76.   repeat with wScan = 1 to count(bulletData)
  77.     if (bulletData[wScan][1] = 0) and (validSlot = 0) then
  78.       validSlot = wScan
  79.     end if
  80.   end repeat
  81.   if validSlot <> 0 then
  82.     wSprite = bulletSO + validSlot
  83.     bDuration = bulletReferenceIndex[bType][2]
  84.     bSpeed = bulletReferenceIndex[bType][3]
  85.     bSounds = bulletReferenceIndex[bType][8]
  86.     bulletData[validSlot] = [1, bType, bOwner, [bLoc, bMomentum, bAim, bSpeed], [bDuration, btarget]]
  87.     playSound(bSounds[1])
  88.     set the member of sprite wSprite to bulletReferenceIndex[bType][1][1]
  89.     sprite(wSprite).rotation = bAim
  90.   end if
  91. end
  92.  
  93. on initializeShipReferenceIndex
  94.   global shipReferenceIndex
  95.   shipReferenceIndex = []
  96.   schematicsBit = [150, 80, 0, 250, 0]
  97.   engineeringBit = [6, 3, 5, 2, 60]
  98.   mainWeaponsData = [1, 50, 4, 2000]
  99.   parametersBit = [100, 2000, 2, 100, 3500]
  100.   repairBayBit = [20, 0, 0, 0]
  101.   add(shipReferenceIndex, ["Fighter", schematicsBit, engineeringBit, mainWeaponsData, parametersBit, repairBayBit])
  102.   schematicsBit = [150, 80, 0, 250, 0]
  103.   engineeringBit = [6, 3, 4, 2, 60]
  104.   mainWeaponsData = [3, 50, 30, 3000]
  105.   parametersBit = [180, 2400, 1, 110, 4500]
  106.   repairBayBit = [30, 0, 0, 0]
  107.   add(shipReferenceIndex, ["GunBoat", schematicsBit, engineeringBit, mainWeaponsData, parametersBit, repairBayBit])
  108.   schematicsBit = [150, 80, 0, 250, 0]
  109.   engineeringBit = [6, 3, 6, 2, 60]
  110.   mainWeaponsData = [2, 50, 20, 4000]
  111.   parametersBit = [60, 1800, 3, 90, 4000]
  112.   repairBayBit = [15, 0, 0, 0]
  113.   add(shipReferenceIndex, ["Stealther", schematicsBit, engineeringBit, mainWeaponsData, parametersBit, repairBayBit])
  114.   schematicsBit = [150, 80, 0, 350, 0]
  115.   engineeringBit = [6, 3, 4, 1, 60]
  116.   mainWeaponsData = [3, 50, 18, 3000]
  117.   parametersBit = [250, 1000, 1, 250, 2000]
  118.   repairBayBit = [30, 0, 0, 0]
  119.   add(shipReferenceIndex, ["Destroyer", schematicsBit, engineeringBit, mainWeaponsData, parametersBit, repairBayBit])
  120.   schematicsBit = [150, 80, 0, 300, 0]
  121.   engineeringBit = [6, 3, 4, 1, 60]
  122.   mainWeaponsData = [2, 50, 4, 4000]
  123.   parametersBit = [300, 1000, 1, 350, 2500]
  124.   repairBayBit = [30, 0, 0, 0]
  125.   add(shipReferenceIndex, ["Cruiser", schematicsBit, engineeringBit, mainWeaponsData, parametersBit, repairBayBit])
  126.   schematicsBit = [175, 80, 1, 350, 0]
  127.   engineeringBit = [6, 6, 0, 0, 0]
  128.   mainWeaponsData = [4, 50, 180, 8000]
  129.   parametersBit = [400, 4000, 1, 500, 5000]
  130.   repairBayBit = [15, 1, 1, 1]
  131.   add(shipReferenceIndex, ["Home Base", schematicsBit, engineeringBit, mainWeaponsData, parametersBit, repairBayBit])
  132.   schematicsBit = [250, 80, 1, 350, 250]
  133.   engineeringBit = [6, 3, 2, 1, 0]
  134.   mainWeaponsData = [5, 50, 100, 3500]
  135.   parametersBit = [600, 1000, 1, 500, 15000]
  136.   repairBayBit = [10, 0, 0, 0]
  137.   add(shipReferenceIndex, ["Saucer 1", schematicsBit, engineeringBit, mainWeaponsData, parametersBit, repairBayBit])
  138.   schematicsBit = [150, 80, 1, 250, 100]
  139.   engineeringBit = [6, 3, 4, 1, 20]
  140.   mainWeaponsData = [6, 50, 120, 8000]
  141.   parametersBit = [350, 6000, 1, 500, 2000]
  142.   repairBayBit = [40, 0, 0, 0]
  143.   add(shipReferenceIndex, ["Saucer 2", schematicsBit, engineeringBit, mainWeaponsData, parametersBit, repairBayBit])
  144.   schematicsBit = [125, 80, 1, 250, 75]
  145.   engineeringBit = [6, 3, 4, 1, 40]
  146.   mainWeaponsData = [1, 50, 15, 1800]
  147.   parametersBit = [100, 1800, 1, 500, 2000]
  148.   repairBayBit = [40, 0, 0, 0]
  149.   add(shipReferenceIndex, ["Saucer 3", schematicsBit, engineeringBit, mainWeaponsData, parametersBit, repairBayBit])
  150.   schematicsBit = [100, 80, 1, 250, 50]
  151.   engineeringBit = [6, 3, 4, 1, 60]
  152.   mainWeaponsData = [3, 50, 40, 3000]
  153.   parametersBit = [80, 3000, 1, 500, 4000]
  154.   repairBayBit = [40, 0, 0, 0]
  155.   add(shipReferenceIndex, ["Saucer 4", schematicsBit, engineeringBit, mainWeaponsData, parametersBit, repairBayBit])
  156.   schematicsBit = [75, 80, 1, 225, 20]
  157.   engineeringBit = [6, 3, 4, 1, 50]
  158.   mainWeaponsData = [2, 50, 30, 2500]
  159.   parametersBit = [40, 2500, 1, 500, 3000]
  160.   repairBayBit = [40, 0, 0, 0]
  161.   add(shipReferenceIndex, ["Saucer 5", schematicsBit, engineeringBit, mainWeaponsData, parametersBit, repairBayBit])
  162.   schematicsBit = [40, 80, 1, 200, 10]
  163.   engineeringBit = [6, 3, 4, 3, 65]
  164.   mainWeaponsData = [1, 50, 35, 2000]
  165.   parametersBit = [20, 2000, 1, 500, 2500]
  166.   repairBayBit = [40, 0, 0, 0]
  167.   add(shipReferenceIndex, ["Saucer 6", schematicsBit, engineeringBit, mainWeaponsData, parametersBit, repairBayBit])
  168. end
  169.  
  170. on addShip sOwner, sType, sLoc, sMomentum, sAim, slaveState
  171.   global shipReferenceIndex, mostRecentMaster
  172.   validSlot = 0
  173.   repeat with wScan = 1 to count(shipData)
  174.     if (shipData[wScan][1] = 0) and (validSlot = 0) then
  175.       validSlot = wScan
  176.     end if
  177.   end repeat
  178.   if validSlot <> 0 then
  179.     if slaveState = 0 then
  180.       mostRecentMaster = validSlot
  181.       sMaster = 0
  182.     else
  183.       sMaster = mostRecentMaster
  184.     end if
  185.     wSprite = shipSO + validSlot
  186.     killingTarget = 0
  187.     repairStatus = [0, 0]
  188.     shipData[validSlot] = [1, sType, sOwner, [sLoc, sMomentum, sAim, 0], [0, 0, 0, 0, 0], sMaster, killingTarget, repairStatus]
  189.     memName = shipReferenceIndex[sType][1]
  190.     set the member of sprite wSprite to memName
  191.     sprite(wSprite).rotation = sAim
  192.   end if
  193. end
  194.  
  195. on moveBulletData
  196.   global bulletReferenceIndex, bulletSequenceTimer, shipReferenceIndex, specialPlayerStats, launchShrike, shrikeDestination
  197.   bulletSequenceTimer = bulletSequenceTimer + 1
  198.   repeat with wScan = 1 to count(bulletData)
  199.     if bulletData[wScan][1] = 1 then
  200.       wSprite = bulletSO + wScan
  201.       bulletDataBit_Loc = bulletData[wScan][4]
  202.       bulletDataBit_Status = bulletData[wScan][5]
  203.       if bulletDataBit_Status[1] <= 0 then
  204.         set the loc of sprite wSprite to point(-50, -50)
  205.         bulletData[wScan][1] = 0
  206.         next repeat
  207.       end if
  208.       bSpeed = bulletReferenceIndex[bulletData[wScan][2]][3]
  209.       hitsAllHostile = 0
  210.       myTarget = bulletData[wScan][5][2]
  211.       homingState = bulletReferenceIndex[bulletData[wScan][2]][6]
  212.       if (myTarget <> 0) and (homingState = 1) then
  213.         bAim = findAngle(bulletDataBit_Loc[1], shipData[myTarget][4][1])
  214.         sprite(wSprite).rotation = bAim
  215.       else
  216.         if (myTarget <> 0) and (homingState = 2) then
  217.           bAim = findAngle(bulletDataBit_Loc[1], myTarget)
  218.           sprite(wSprite).rotation = bAim
  219.         else
  220.           hitsAllHostile = 1
  221.           bAim = bulletDataBit_Loc[3]
  222.         end if
  223.       end if
  224.       locY = integer(cos(bAim * PI / 180) * -bSpeed)
  225.       locX = integer(sin(bAim * PI / 180) * bSpeed)
  226.       bulletDataBit_Loc[1] = bulletDataBit_Loc[1] + bulletDataBit_Loc[2] + point(locX, locY)
  227.       bulletDataBit_Status[1] = bulletDataBit_Status[1] - 1
  228.       termination = 0
  229.       selfGov = bulletData[wScan][3]
  230.       targetHit = 0
  231.       if (homingState = 1) and (myTarget <> 0) then
  232.         targRadius = shipReferenceIndex[shipData[myTarget][3]][2][1]
  233.         shipLoc = shipData[myTarget][4][1]
  234.         bulletLoc = bulletDataBit_Loc[1]
  235.         if findDistance(shipLoc, bulletLoc) <= (50 + targRadius) then
  236.           termination = 1
  237.           targetHit = myTarget
  238.         end if
  239.       else
  240.         if (homingState = 2) and (myTarget <> 0) then
  241.           shipLoc = myTarget
  242.           bulletLoc = bulletDataBit_Loc[1]
  243.           if findDistance(shipLoc, bulletLoc) <= (250 + targRadius) then
  244.             dealBlast(bulletLoc, 500, 1000)
  245.             termination = 1
  246.             targetHit = 0
  247.           end if
  248.           specialPlayerStats[5] = 1000
  249.         else
  250.           repeat with wShipScan = 1 to count(shipData)
  251.             if shipData[wShipScan][1] = 1 then
  252.               if selfGov <> shipData[wShipScan][3] then
  253.                 targRadius = shipReferenceIndex[shipData[wShipScan][2]][2][1]
  254.                 shipLoc = shipData[wShipScan][4][1]
  255.                 bulletLoc = bulletDataBit_Loc[1]
  256.                 if findDistance(shipLoc, bulletLoc) <= (150 + targRadius) then
  257.                   termination = 1
  258.                   targetHit = wShipScan
  259.                 end if
  260.               end if
  261.             end if
  262.           end repeat
  263.         end if
  264.       end if
  265.       bType = bulletData[wScan][2]
  266.       particleProfile = bulletReferenceIndex[bType][5]
  267.       if termination = 0 then
  268.         sequenceList = bulletReferenceIndex[bType][1]
  269.         if particleProfile[2] <> 0 then
  270.           if ((wScan + bulletSequenceTimer) mod particleProfile[3]) = 0 then
  271.             addparticle(particleProfile[2], bulletDataBit_Loc[1] - bulletDataBit_Loc[2], bulletDataBit_Loc[2])
  272.           end if
  273.         end if
  274.         if bType = 7 then
  275.           specialPlayerStats[5] = 1000
  276.         end if
  277.         set the member of sprite wSprite to sequenceList[(bulletSequenceTimer mod count(sequenceList)) + 1]
  278.         set the loc of sprite wSprite to (bulletDataBit_Loc[1] - playerViewPoint) / 10
  279.         sprite(wSprite).visible = 1
  280.         next repeat
  281.       end if
  282.       if bType = 10 then
  283.         if specialPlayerStats[5] = 0 then
  284.           launchShrike = 1
  285.           shrikeDestination = bulletDataBit_Loc[1]
  286.         end if
  287.       end if
  288.       if bType = 7 then
  289.         specialPlayerStats[5] = 1000
  290.         member("Mega Cannon Status").text = "Reloading"
  291.       else
  292.         params = shipData[targetHit][5]
  293.         if targetHit = 1 then
  294.           params[1] = params[1] + integer(bulletReferenceIndex[bType][7] / 2)
  295.         else
  296.           params[1] = params[1] + bulletReferenceIndex[bType][7]
  297.         end if
  298.         addparticle(particleProfile[1], bulletDataBit_Loc[1], bulletDataBit_Loc[2])
  299.         if targetHit = 1 then
  300.           playSound("player Is Hit SFX")
  301.         end if
  302.       end if
  303.       set the loc of sprite wSprite to point(-50, -50)
  304.       bulletData[wScan][1] = 0
  305.     end if
  306.   end repeat
  307. end
  308.  
  309. on dealBlast blastloc, blastRadius, blastDamage
  310.   global shipData, shipReferenceIndex
  311.   rRing = random(360) / 6
  312.   repeat with wRepairSpark = 1 to 6
  313.     rWidth = 100
  314.     shipAim = (360 / 6 * wRepairSpark) + rRing
  315.     locY2 = integer(cos(shipAim * PI / 180) * -rWidth)
  316.     locX2 = integer(sin(shipAim * PI / 180) * rWidth)
  317.     addparticle(9, blastloc + point(locX2, locY2), point(locX2, locY2) / 5)
  318.   end repeat
  319.   totalShipsToasted = 0
  320.   repeat with wShipScan = 1 to count(shipData)
  321.     if shipData[wShipScan][1] = 1 then
  322.       targRadius = shipReferenceIndex[shipData[wShipScan][3]][2][1]
  323.       shipLoc = shipData[wShipScan][4][1]
  324.       bulletLoc = blastloc
  325.       if findDistance(shipLoc, blastloc) <= (blastRadius + targRadius) then
  326.         shipData[wShipScan][5][1] = shipData[wShipScan][5][1] + blastDamage
  327.         totalShipsToasted = totalShipsToasted + 1
  328.       end if
  329.     end if
  330.   end repeat
  331. end
  332.  
  333. on moveShips
  334.   global shipReferenceIndex, levelScore, totalActiveShips, totalrangedShips, totalShipsRecord, totalEnemyShips, searchAItimer, hitFirstTime, playerSelectedWeapon, launchShrike, shrikeDestination, specialPlayerStats
  335.   harvestInput()
  336.   totalActiveShips = 0
  337.   totalrangedShips = 0
  338.   totalEnemyShips = 0
  339.   activeList = []
  340.   centerLoc = shipData[1][4][1]
  341.   shipAim = shipData[1][4][3]
  342.   formationControlPoints = []
  343.   repeat with wPoint = 1 to 50
  344.     locY = integer(cos((shipAim + 120) * PI / 180) * -(wPoint * 300))
  345.     locX = integer(sin((shipAim + 120) * PI / 180) * (wPoint * 300))
  346.     add(formationControlPoints, shipData[1][4][1] + point(locX, locY))
  347.     locY = integer(cos((shipAim - 120) * PI / 180) * -(wPoint * 300))
  348.     locX = integer(sin((shipAim - 120) * PI / 180) * (wPoint * 300))
  349.     add(formationControlPoints, centerLoc + point(locX, locY))
  350.   end repeat
  351.   totalForms = 0
  352.   searchAItimer = searchAItimer + 1
  353.   if searchAItimer > count(shipData) then
  354.     searchAItimer = 1
  355.   end if
  356.   repeat with wShip = 1 to count(shipData)
  357.     if shipData[wShip][1] = 1 then
  358.       totalActiveShips = totalActiveShips + 1
  359.       activeShipType = shipData[wShip][2]
  360.       shipDataBit_Loc = shipData[wShip][4]
  361.       shipDataBit_Status = shipData[wShip][5]
  362.       if shipData[wShip][3] = 2 then
  363.         totalEnemyShips = totalEnemyShips + 1
  364.       end if
  365.       if findDistance(shipDataBit_Loc[1], playerViewPoint) <= 100000 then
  366.         add(activeList, 1)
  367.         totalrangedShips = totalrangedShips + 1
  368.         shipParameters = shipData[wShip][5]
  369.         weaponRef = shipReferenceIndex[shipData[wShip][2]][4]
  370.         paramsRef = shipReferenceIndex[shipData[wShip][2]][5]
  371.         wSprite = shipSO + wShip
  372.         engineeringBit = shipReferenceIndex[activeShipType][3]
  373.         maxSpinSpeed = engineeringBit[1]
  374.         spinSpeed = engineeringBit[2]
  375.         shipAccelRate = engineeringBit[3]
  376.         shipDecelRate = engineeringBit[4]
  377.         shipTerminalVelocity = engineeringBit[5]
  378.         repairBayBit = shipReferenceIndex[activeShipType][6]
  379.         if wShip = 1 then
  380.           literalInputString = inputString
  381.         else
  382.           literalInputString = [0, 0, 0, 0, 0, 0, 0, 0]
  383.           masterShipID = shipData[wShip][6]
  384.           AI_Objective = #HangOut
  385.           if masterShipID <> 0 then
  386.             distanceFromMaster = findDistance(shipData[wShip][4][1], shipData[masterShipID][4][1])
  387.             if distanceFromMaster > 1000 then
  388.               AI_Objective = #FindMaster
  389.             else
  390.               AI_Objective = #SeekFormation
  391.             end if
  392.           end if
  393.           killingTarget = shipData[wShip][7]
  394.           if killingTarget = 0 then
  395.             aquireNewTarget = 1
  396.           else
  397.             if shipData[killingTarget][1] = 0 then
  398.               shipData[wShip][7] = 0
  399.               aquireNewTarget = 1
  400.             end if
  401.           end if
  402.           if searchAItimer = wShip then
  403.             aquireNewTarget = 1
  404.           end if
  405.           if aquireNewTarget = 1 then
  406.             selfGovernment = shipData[wShip][3]
  407.             testRange = paramsRef[5]
  408.             testUnit = 0
  409.             repeat with wScanner = 1 to count(shipData)
  410.               if shipData[wScanner][1] = 1 then
  411.                 targetGovernment = shipData[wScanner][3]
  412.                 if selfGovernment <> targetGovernment then
  413.                   scannerRange = findDistance(shipData[wScanner][4][1], shipData[wShip][4][1])
  414.                   if scannerRange < testRange then
  415.                     testRange = scannerRange
  416.                     testUnit = wScanner
  417.                   end if
  418.                 end if
  419.               end if
  420.             end repeat
  421.             shipData[wShip][7] = testUnit
  422.           else
  423.             testUnit = shipData[wShip][7]
  424.             testRange = findDistance(shipData[testUnit][4][1], shipData[wShip][4][1])
  425.           end if
  426.           if testUnit <> 0 then
  427.             if testRange > weaponRef[4] then
  428.               AI_Objective = #FindEnemy
  429.               killingTarget = shipData[wShip][7]
  430.             else
  431.               AI_Objective = #AttackEnemy
  432.               killingTarget = shipData[wShip][7]
  433.             end if
  434.           end if
  435.           case AI_Objective of
  436.             #HangOut:
  437.               literalInputString[3] = 1
  438.             #FindMaster:
  439.               targetVector = findAngle(shipData[masterShipID][4][1], shipData[wShip][4][1]) mod 360
  440.               selfVector = shipData[wShip][4][3] mod 360
  441.               maxVector = spinSpeed
  442.               realVector = targetVector - selfVector
  443.               maxX = integer(sin(maxVector * PI / 180) * 100)
  444.               locX = integer(sin(realVector * PI / 180) * 100)
  445.               if (locX < abs(maxX)) and (locX > (0 - abs(maxX))) then
  446.                 shipData[wShip][4][3] = targetVector + 180
  447.               else
  448.                 if locX > 0 then
  449.                   literalInputString[1] = 1
  450.                 else
  451.                   literalInputString[2] = 1
  452.                 end if
  453.               end if
  454.               literalInputString[4] = 1
  455.             #SeekFormation:
  456.               literalInputString[3] = 1
  457.             #FindEnemy:
  458.               targetVector = findAngle(shipData[killingTarget][4][1], shipData[wShip][4][1]) mod 360
  459.               selfVector = shipData[wShip][4][3] mod 360
  460.               maxVector = spinSpeed
  461.               realVector = targetVector - selfVector
  462.               maxX = integer(sin(maxVector * PI / 180) * 100)
  463.               locX = integer(sin(realVector * PI / 180) * 100)
  464.               if (locX < abs(maxX)) and (locX > (0 - abs(maxX))) then
  465.                 shipData[wShip][4][3] = targetVector + 180
  466.               else
  467.                 if locX > 0 then
  468.                   literalInputString[1] = 1
  469.                 else
  470.                   literalInputString[2] = 1
  471.                 end if
  472.               end if
  473.               literalInputString[4] = 1
  474.             #AttackEnemy:
  475.               targetVector = findAngle(shipData[killingTarget][4][1], shipData[wShip][4][1]) mod 360
  476.               selfVector = shipData[wShip][4][3] mod 360
  477.               maxVector = spinSpeed
  478.               realVector = targetVector - selfVector
  479.               maxX = integer(sin(maxVector * PI / 180) * 100)
  480.               locX = integer(sin(realVector * PI / 180) * 100)
  481.               if (locX < abs(maxX)) and (locX > (0 - abs(maxX))) then
  482.                 shipData[wShip][4][3] = targetVector + 180
  483.               else
  484.                 if locX > 0 then
  485.                   literalInputString[1] = 1
  486.                 else
  487.                   literalInputString[2] = 1
  488.                 end if
  489.               end if
  490.               literalInputString[3] = 1
  491.               literalInputString[5] = 1
  492.           end case
  493.         end if
  494.         shipIsdead = 0
  495.         if wShip = 1 then
  496.           shieldBonus = specialPlayerStats[1]
  497.         else
  498.           shieldBonus = 0
  499.         end if
  500.         if shipParameters[1] >= (paramsRef[1] + shieldBonus) then
  501.           shipIsdead = 1
  502.         end if
  503.         if shipIsdead = 1 then
  504.           literalInputString = [0, 0, 1, 0, 0, 0, 0, 0]
  505.         end if
  506.         if literalInputString[1] = 1 then
  507.           shipDataBit_Loc[4] = shipDataBit_Loc[4] - spinSpeed
  508.           if shipDataBit_Loc[4] < (0 - maxSpinSpeed) then
  509.             shipDataBit_Loc[4] = 0 - maxSpinSpeed
  510.           end if
  511.         else
  512.           if literalInputString[2] = 1 then
  513.             shipDataBit_Loc[4] = shipDataBit_Loc[4] + spinSpeed
  514.             if shipDataBit_Loc[4] > maxSpinSpeed then
  515.               shipDataBit_Loc[4] = maxSpinSpeed
  516.             end if
  517.           else
  518.             repeat with wRep = 1 to spinSpeed
  519.               if shipDataBit_Loc[4] > 0 then
  520.                 shipDataBit_Loc[4] = shipDataBit_Loc[4] - 1
  521.                 next repeat
  522.               end if
  523.               if shipDataBit_Loc[4] < 0 then
  524.                 shipDataBit_Loc[4] = shipDataBit_Loc[4] + 1
  525.               end if
  526.             end repeat
  527.           end if
  528.         end if
  529.         if literalInputString[4] = 1 then
  530.           shipAim = shipDataBit_Loc[3]
  531.           locY = integer(cos(shipAim * PI / 180) * -shipAccelRate)
  532.           locX = integer(sin(shipAim * PI / 180) * shipAccelRate)
  533.           shipDataBit_Loc[2] = shipDataBit_Loc[2] + point(locX, locY)
  534.           shipAim = shipDataBit_Loc[3]
  535.           locY1 = integer(cos(shipAim * PI / 180) * -120)
  536.           locX1 = integer(sin(shipAim * PI / 180) * 120)
  537.           rWidth = random(100) - 50
  538.           shipAim = shipDataBit_Loc[3]
  539.           locY2 = integer(cos((shipAim + 90) * PI / 180) * -rWidth)
  540.           locX2 = integer(sin((shipAim + 90) * PI / 180) * rWidth)
  541.         else
  542.           if literalInputString[3] = 1 then
  543.             shipAim = findAngle(shipDataBit_Loc[2], point(0, 0))
  544.             shipSlowDist = findDistance(shipDataBit_Loc[2], point(0, 0))
  545.             if shipSlowDist > shipDecelRate then
  546.               locY = integer(cos(shipAim * PI / 180) * -shipDecelRate)
  547.               locX = integer(sin(shipAim * PI / 180) * shipDecelRate)
  548.               shipDataBit_Loc[2] = shipDataBit_Loc[2] + point(locX, locY)
  549.             else
  550.               shipDataBit_Loc[2] = point(0, 0)
  551.             end if
  552.           end if
  553.         end if
  554.         canRepairNow = 0
  555.         if shipDataBit_Loc[2] = point(0, 0) then
  556.           if shipData[wShip][8][1] > 0 then
  557.             shipData[wShip][8][1] = shipData[wShip][8][1] - 1
  558.           else
  559.             shipData[wShip][8][1] = repairBayBit[1]
  560.             if repairBayBit[3] = 1 then
  561.               canRepairNow = 1
  562.             end if
  563.           end if
  564.         else
  565.           shipData[wShip][8][1] = 60
  566.         end if
  567.         if canRepairNow = 1 then
  568.           repairID = 0
  569.           damageReport = 0
  570.           selfGovernment = shipData[wShip][3]
  571.           testRange = 1500
  572.           testUnit = 0
  573.           repeat with repairScanner = 1 to count(shipData)
  574.             if shipData[repairScanner][1] = 1 then
  575.               if repairScanner <> wShip then
  576.                 targetGovernment = shipData[repairScanner][3]
  577.                 if selfGovernment = targetGovernment then
  578.                   if shipData[repairScanner][4][2] = point(0, 0) then
  579.                     if shipData[repairScanner][5][1] > 0 then
  580.                       scannerRange = findDistance(shipData[repairScanner][4][1], shipData[wShip][4][1])
  581.                       if scannerRange < testRange then
  582.                         testRange = scannerRange
  583.                         testUnit = repairScanner
  584.                       end if
  585.                     end if
  586.                   end if
  587.                 end if
  588.               end if
  589.             end if
  590.           end repeat
  591.           if testUnit <> 0 then
  592.             addparticle(16, shipData[testUnit][4][1], shipDataBit_Loc[2])
  593.             repeat with wRepair = 1 to 5
  594.               if shipData[testUnit][5][1] > 0 then
  595.                 shipData[testUnit][5][1] = shipData[testUnit][5][1] - 1
  596.                 shipData[wShip][5][2] = shipData[wShip][5][2] + 1
  597.               end if
  598.             end repeat
  599.             if testUnit = 1 then
  600.               playSound("powerup SFX")
  601.             end if
  602.           end if
  603.         end if
  604.         if wShip = 1 then
  605.           validWeaps = [1, 0, 0, 0, 0]
  606.           if specialPlayerStats[2] > 0 then
  607.             validWeaps[2] = 1
  608.           end if
  609.           if specialPlayerStats[3] > 0 then
  610.             validWeaps[3] = 1
  611.           end if
  612.           if specialPlayerStats[4] > 0 then
  613.             validWeaps[4] = 1
  614.           end if
  615.           if specialPlayerStats[5] = 0 then
  616.             validWeaps[5] = 1
  617.           end if
  618.           if literalInputString[7] = 1 then
  619.             if hitFirstTime = 0 then
  620.               hitFirstTime = 1
  621.               fineWithMe = 0
  622.               repeat while fineWithMe = 0
  623.                 playerSelectedWeapon = playerSelectedWeapon + 1
  624.                 if playerSelectedWeapon > 5 then
  625.                   playerSelectedWeapon = 1
  626.                 end if
  627.                 fineWithMe = validWeaps[playerSelectedWeapon]
  628.               end repeat
  629.               set the member of sprite 787 to "WBG 1"
  630.               set the member of sprite 789 to "WBG 1"
  631.               set the member of sprite 792 to "WBG 1"
  632.               set the member of sprite 795 to "WBG 1"
  633.               set the member of sprite 798 to "WBG 1"
  634.               set the member of sprite [787, 789, 792, 795, 798][playerSelectedWeapon] to "WBG 2"
  635.             else
  636.             end if
  637.           else
  638.             hitFirstTime = 0
  639.           end if
  640.         end if
  641.         if shipDataBit_Status[2] > 0 then
  642.           shipDataBit_Status[2] = shipDataBit_Status[2] - 1
  643.         end if
  644.         if literalInputString[5] = 1 then
  645.           if shipDataBit_Status[2] <= 0 then
  646.             weaponBit = shipReferenceIndex
  647.             wingGunAim = shipDataBit_Loc[3]
  648.             gSpread = weaponRef[2]
  649.             if shipDataBit_Status[5] = 1 then
  650.               locY = integer(cos((wingGunAim + 90) * PI / 180) * -gSpread)
  651.               locX = integer(sin((wingGunAim + 90) * PI / 180) * gSpread)
  652.               shipDataBit_Status[5] = 0
  653.             else
  654.               locY = integer(cos((wingGunAim - 90) * PI / 180) * -gSpread)
  655.               locX = integer(sin((wingGunAim - 90) * PI / 180) * gSpread)
  656.               shipDataBit_Status[5] = 1
  657.             end if
  658.             closestTarget = 0
  659.             closestDistance = 9000
  660.             selfGov = shipData[wShip][3]
  661.             repeat with wShipScan = 1 to count(shipData)
  662.               if shipData[wShipScan][1] = 1 then
  663.                 if selfGov <> shipData[wShipScan][3] then
  664.                   shipLoc = shipData[wShipScan][4][1]
  665.                   TargetLoc = shipData[wShipScan][4][1]
  666.                   scanDistresult = findDistance(shipLoc, shipDataBit_Loc[1])
  667.                   if scanDistresult <= closestDistance then
  668.                     termination = 1
  669.                     closestTarget = wShipScan
  670.                     closestDistance = scanDistresult
  671.                   end if
  672.                 end if
  673.               end if
  674.             end repeat
  675.             if wShip = 1 then
  676.               outtaAmmo = 0
  677.               bulletType = [weaponRef[1], 8, 9, 2, 10][playerSelectedWeapon]
  678.               heatUp = [weaponRef[3], 16, 30, 2, 30][playerSelectedWeapon]
  679.               case playerSelectedWeapon of
  680.                 2:
  681.                   specialPlayerStats[2] = specialPlayerStats[2] - 1
  682.                   member("Ammo Display 1").text = string(specialPlayerStats[2])
  683.                   if specialPlayerStats[2] <= 0 then
  684.                     outtaAmmo = 1
  685.                   end if
  686.                 3:
  687.                   specialPlayerStats[3] = specialPlayerStats[3] - 1
  688.                   member("Ammo Display 2").text = string(specialPlayerStats[3])
  689.                   if specialPlayerStats[3] <= 0 then
  690.                     outtaAmmo = 1
  691.                   end if
  692.                 4:
  693.                   specialPlayerStats[4] = specialPlayerStats[4] - 1
  694.                   member("Ammo Display 3").text = string(specialPlayerStats[4])
  695.                   if specialPlayerStats[4] <= 0 then
  696.                     outtaAmmo = 1
  697.                   end if
  698.               end case
  699.               if outtaAmmo = 1 then
  700.                 set the member of sprite 787 to "WBG 2"
  701.                 set the member of sprite 789 to "WBG 1"
  702.                 set the member of sprite 792 to "WBG 1"
  703.                 set the member of sprite 795 to "WBG 1"
  704.                 set the member of sprite 798 to "WBG 1"
  705.                 playerSelectedWeapon = 1
  706.               end if
  707.             else
  708.               bulletType = weaponRef[1]
  709.               heatUp = weaponRef[3]
  710.             end if
  711.             addBullet(shipData[wShip][3], bulletType, shipDataBit_Loc[1] + point(locX, locY), shipDataBit_Loc[2], shipDataBit_Loc[3], closestTarget)
  712.             shipDataBit_Status[2] = heatUp
  713.           end if
  714.         else
  715.         end if
  716.       end if
  717.       if findDistance(shipDataBit_Loc[2], point(0, 0)) > shipTerminalVelocity then
  718.         driftAngle = findAngle(shipDataBit_Loc[2], point(0, 0))
  719.         locY = integer(cos(driftAngle * PI / 180) * shipTerminalVelocity)
  720.         locX = integer(sin(driftAngle * PI / 180) * -shipTerminalVelocity)
  721.         shipDataBit_Loc[2] = point(locX, locY)
  722.       end if
  723.       shipDataBit_Loc[1] = shipDataBit_Loc[1] + shipDataBit_Loc[2]
  724.       shipDataBit_Loc[3] = shipDataBit_Loc[3] + shipDataBit_Loc[4]
  725.       shipData[wShip][4] = shipDataBit_Loc
  726.       shipData[wShip][5] = shipDataBit_Status
  727.       if shipIsdead = 1 then
  728.         repeat with wAim = 1 to 10
  729.           driftAngle = wAim * 36
  730.           driftPower = 25 + random(100)
  731.           locY = integer(cos(driftAngle * PI / 180) * driftPower)
  732.           locX = integer(sin(driftAngle * PI / 180) * -driftPower)
  733.           addparticle(6, shipDataBit_Loc[1], shipDataBit_Loc[2] + point(locX, locY))
  734.         end repeat
  735.         if random(3) = 1 then
  736.           addPowerup(random(4), shipDataBit_Loc[1], shipDataBit_Loc[2])
  737.         end if
  738.         addparticle(9, shipDataBit_Loc[1], shipDataBit_Loc[2])
  739.         shipData[wShip][1] = 0
  740.         set the loc of sprite wSprite to point(-50, -50)
  741.         if shipTerminalVelocity = 0 then
  742.           playSound("Base Explode SFX")
  743.         else
  744.           if wShip = 1 then
  745.             playSound("player Explode SFX")
  746.           else
  747.             playSound("Enemy Explosion SFX")
  748.           end if
  749.         end if
  750.         levelScore = levelScore + shipReferenceIndex[activeShipType][2][5]
  751.         next repeat
  752.       end if
  753.       if shipData[wShip][2] = 6 then
  754.         if launchShrike = 1 then
  755.           set the member of sprite 787 to "WBG 2"
  756.           set the member of sprite 789 to "WBG 1"
  757.           set the member of sprite 792 to "WBG 1"
  758.           set the member of sprite 795 to "WBG 1"
  759.           set the member of sprite 798 to "WBG 1"
  760.           playerSelectedWeapon = 1
  761.           launchShrike = 0
  762.           member("Mega Cannon Status").text = "Incoming!!!"
  763.           addBullet(shipData[wShip][3], 7, shipDataBit_Loc[1], point(0, 0), 0, shrikeDestination)
  764.         end if
  765.       end if
  766.       wSprite = shipSO + wShip
  767.       if findDistance(playerViewPoint + point(2900, 2200), shipDataBit_Loc[1]) <= 3800 then
  768.         if activeShipType = 1 then
  769.           if literalInputString[4] = 1 then
  770.             set the member of sprite wSprite to "Fighter " & string((searchAItimer mod 6) + 1)
  771.           else
  772.             set the member of sprite wSprite to "Fighter Idle"
  773.           end if
  774.         end if
  775.         sphereState = shipReferenceIndex[activeShipType][2][3]
  776.         if sphereState = 0 then
  777.           sprite(wSprite).rotation = shipDataBit_Loc[3]
  778.         else
  779.           sprite(wSprite).rotation = 0
  780.         end if
  781.         set the loc of sprite wSprite to (shipDataBit_Loc[1] - playerViewPoint) / 10
  782.         if wShip = 1 then
  783.           set the height of sprite 783 to paramsRef[1] + specialPlayerStats[1]
  784.           set the height of sprite 784 to paramsRef[1] - shipData[1][5][1] + specialPlayerStats[1]
  785.         end if
  786.         sprite(wSprite).visible = 1
  787.       else
  788.         sprite(wSprite).visible = 0
  789.       end if
  790.       add(activeList, 1)
  791.     end if
  792.   end repeat
  793.   if totalActiveShips <> totalShipsRecord then
  794.     totalShipsRecord = totalActiveShips
  795.   end if
  796. end
  797.